home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-27 | 112.5 KB | 2,765 lines |
- DEVPAC 2 PART 1
-
- Originaly typed in for DEVPAC ST by THE ANIMAL HOUSE. Converted to
- DEVPAC AMIGA by PARASITE of LSD. Over 12 continueous hours of typing
- to convert these so I hope you appreciate them!
-
-
- CHAPTER 1: INTRODUCTION
-
- ALWAYS MAKE A BACK-UP
- Before using Devpac AMIGA you should make a back-up copy of
- the original disk and put the original away in a safe place. It is not
- copy-protected to allow easy back-up and to avoid inconvenience. This
- disk may be backed up using the Workbench or any back-up utility.
-
- NOTE: The original DEVPAC master disk had a technical support
- serial registration number, but you wont get this!.
-
- REGISTRATION CARD
- Enclosed with the manual is a registration card (but not for
- you, and you also get a free 68000 Pocket Guide (£2.95 from any
- good bookshop.)
-
- THE README FILE
- As with all Hisoft products Devpac AMIGA is continually being
- improved and the latest details cannot be included in this manual
- may be found in the README.S file on the disk. If you are not already
- in th CLI you should wait for any disk activity to stop. Press CTRL
- and both AMIGA keys (A software reset), insert your DEVPAC disk. Once
- in the CLI this file should be read by entering the command:
-
- type readme (RETURN)
-
- This display can be paused by holding down the menu button on the
- mouse.
-
- INTRODUCTION TO THE CLI
- Like most other programming developement tools, DeVPAC AMIGA
- is designed to be run from the CLI (Command Line Interface). If you
- examine the disk from the Workbench icon interface you won't see many
- icons on the disk because of this.
- The CLI is deliberatly hidden from the average user, but as a
- programmer you will need to use it, although most of your developement
- time will be spent in th DEVPAC programs rather than the CLI.
- DEVPAC disk one is a modified Workbench disk and to start with
- you should boot your machine as normal, with a kickstart disk if
- required, but when asked for workbench, insert DEVPAC disk one. If you
- have already booted from another disk, you should wait for all disk
- activity to stop, insert DEVPAC and preform a software reset.
- The CLI is similar in concept to other non-iconic computers,
- such as those running MS-DOS or CP/m. It works by you entering
- commands such as:
-
- dir (RETURN)
-
- to get a directory of the disk. There is a full description on how to
- use the CLI and tutorial in the AMIGA user manuel.
-
- NOTE: If you have a non-UK keyboard, you may need to modify
- your s/startup-sequence file on your DEVPAC back-up disk, although
- this may have been done for you! See the readme for more details.
-
- BACKUP DETAILS
- Before making your security backups please ensure your master
- disks are write protected. It is recommended the backups made are
- regually virus checked with a reliable virus killer, or life could
- become very nasty!.
-
- ONE-DRIVE SYSTEMS
- Once you have booted the DEVPAC disk one enter the command
-
- diskcopy df0: to df0: (RETURN)
-
- Then follow the prompts given. The disk to copy from is our write-
- protected master disk one the disk to copy to should be a write-
- enabled blank disk. Then repeat the procedure with disk two.
-
- TWO-DRIVE SYSTEMS
- Enter the command:
-
- diskcopy df0: to df1: (RETURN)
-
- inset a write-enabled blank disk in the internal drive, and the write-
- protected DEVPAC disk one in the external drive and follow the prompts
- given. Repeat the procedure with disk two.
-
- MAKING A WORK DISK
- Although you now have a back-up, the disk as supplied dosen't
- have room on it for large programs, and it is best to make one or more
- work disks when you want to start serious programming. Exactly how you
- do this depends on your hardware confuguration.
-
- ONE-DRIVE SYSTEMS
- For single drive users it is best to get rid of as much as you
- can fron the DEVPAC disk. Prime candidates are all .info files
- together with the printer drivers and keymap files not required.
- Deleting Preferances will save space, but this may be useful.
- If you follow these reccomendations the commands required (on
- another backup) would be:
-
- cd df0: (RETURN)
- delete #?.info (RETURN)
- cd devs/printers (RETURN)
- dir (RETURN)
-
- This will produce a list of printer drivers. Use the delete command to
- erase those you do not need.
-
- cd devs/keymaps (RETURN)
- dir (RETURN)
-
- This will produce a list of keymap files. Continue as above.
-
- If space still bets tight you could start deleting the examples
- directory, seldom used include files and some commands in the c
- directory.
-
- TWO-DRIVE SYSTEMS
- Two drive owners are reccomended to keep the workbench disk
- free of all source code, and put such files together with the include
- files on the disk in th external drive. The commands to do this (using
- another back-up) would be:
- (NOTE: The first command formats a blank disk in the external
- drive losing all data. If you are using a pre-formatted disk you don't
- need to do this)
-
- format drive df1: name "source" (RETURN)
-
- Insert a blank disk in the external drive, then press (RETURN) to
- format it.
-
- cd df0: (RETURN)
- makedir df1:include (RETURN)
- makedir df1:examples (RETURN)
- copy include to df1:include all (RETURN)
- copy examples to df1:examples all (RETURN)
- delete include all (RETURN)
- delete examples all (RETURN)
-
- The commands create directories on the external drive for the
- example programs and the include files, then delete them from the disk
- in the internal drive (which must, of course, be a back-up).
-
- You will now probably want to copy the program files from
- DEVPAC disk two to your workbench disk. To do this insert your back-up
- disk two of DEVPAC master disk in df1: and type:
-
- copy df1:c to df0:c all (RETURN)
- cd df1: (RETURN)
-
- This final command changes the default directory to the
- external drive so you can edit source files there more easily. It is
- often worthwile to build such a command into your startup-sequence.
-
- HARD DISK USERS
- Hard disk users should firstly boot from the hard disk, and
- not the DEVPAC workbench disk. Having done this, the DEVPAC disk one
- should be placed in the internal drive and the following commands
- executed, to copy the programs onto the hard disk:
-
- copy df0:c/genam2 to c: (RETURN)
- copy df0:c/monam2 to c: (RETURN)
- copy df0:c/genim2 to c: (RETURN)
-
- Next the two subdirectories should be copied, and this depends
- on your requiremants - for example, you may wish to make a seperate
- DEVPAC directory on your herd disk. Whatever you choose you will need
- to copy the whole of directories "include" and "examples". If you
- choose to have a seperate DEVPAC sub-directory the commands would be
- (assuming dh0: is the name of your hard disk):
-
- makedir dh0:devpac (RETURN)
- copy df0:include to dh0:devpac all (RETURN)
- copy df0:examples to dh0:devpac all (RETURN)
-
- Note that if you put the example directory within another
- directory you will have to change the INCDIR directives at the
- beginning of them for correct assembly.
-
- You will also want to copy the following file from your DEVPAC
- disk two backup.
-
- copy df0:c/blink to dh0:c
-
- It probably isn't worth copying the other files until you need
- them.
-
- THE DEVELOPMENT CYCLE
- The purpose of DEVPAC is to allow you to enter assembly
- language programs, assemble them to machine-code and debug them if
- (or should that be 'when') they don't work. Depending on your
- application, you may also be using a linker to join together seperate
- modules, possibly with the output from a high level language compiler.
- Of course the faster the development cycle, the faster you can get
- your programs up and running and DEVPAC was designed to be as fast and
- powerful as possible. The link stage is optional, as is the Compile
- stage.
-
- DEVPAC DISK CONTENTS
- DEVPAC is supplied on two 3.5" disks, the first a standard
- Workbench 1.2 disk, configured to enter the CLI on boot, and the other
- contains additional files.
-
- DISK 1
- Programs in c directory:
- GENAM2 - Screen editor and control program
- GENIM2 - Assembler
- MONAM2 - Debugger
-
- Other files:
- LIBS/LIBFILE.MONAM - Binary file used by debugger
- LIBS/ARP.LIBRARY - Additional library
- README - Latest details about DEVPAC
-
- Additional subdirectories:
- INCLUDE - Contains files for accessing the operating system.
- EXAMPLES - The source code to various example programs.
-
- DISK 2
- Programs in the c directory:
- BLINK - PD linker
- CONVERTFD - FD file conversion utility
- CONVERTI - Include file conversion utility
-
- + some Workbench files for which there is insufficient room on disk
- one.
-
- Text files:
- BLINK.DOC - Instructions for linker
-
- Additional subdirectories:
- INCLUDE.CBM - The original Commodore include files with comments
- INCLUDE.STRIP - The original Commodore include files without comments
- FD.FILES - The original Commodore fd files. Includes which
- registers are used when calling libraries.
- LIBRARY - Contains amiga.lib, debug.lib
- ARP - Contains parts of Charlie Heaths AmigaDOS replacement
- project (ARP)
-
- HOW TO USE THE MANUAL
- This manual makes no attempt to teach 68000 assembly language
- programming or to detail the instruction set. For the former, the
- bibliography lists suitable books, while for the latter the
- supplied Pocket Guide is very useful. The Appendices give an
- overview of the technical aspects of the AMIGA but they are not
- intended as a complete technical description of the machine.
- This manual is set out in five chapters, this introduction, a
- chapter on the screen editor, a chapter on the macro assembler, a
- chapter on the debugger, then a chapter on the linker. In addition
- there are eight Appendices which detail various additional
- information. We suggest you use the manual in a way that depends
- on what type of user you are:
-
- DEVPAC VERSION 1 USERS
- Turn to Appendix F and read the section describing the new
- features, then read the Reference section of Chapter 4 if you
- intend using MonAM, as it has changed considerably. You will then
- probably want to dip into the manual to read about the new features
- that interest you.
-
- BEGINNERS
- If you are a newcomer to assembly language then we recommend
- that you read one of the books in the Bibliography alongside this
- manual.
- At the end of this chapter there is a simple tutorial which
- you should follow to familiarise yourself with the use of the main
- parts of the program suite.
- Chapter 2 details the editor and is well worth reading,
- though much of Chapter 3, detailing the assembler, is liable to
- mean nothing until you become more experienced. The Overview
- section of Chapter 4, the debugger, is strongly recommended,
- though Appendices can be left for a while.
- Looking at the supplied source code may be helpful.
-
- EXPERIENCED USER
- If you are experienced in the use of 68000 assembly language
- but have not used DEVPAC before then here is a very quick way of
- assembling a source file:
- Load GENAM2, Press Amiga-L and select your file which will
- load into the editor. Press Amiga-A and select the options which you
- require - if generating executable code then click on the Memory
- button for additional speed. Pressing RETURN will start the
- assembler, which may be paused by pressing any key, RETURN resumes.
- Any assembly errors will be remembered and on return to the editor
- you will be placed on the first one. Subsequent errors may be
- found by pressing Amiga-J.
- To run your successfully-assembled program (if assembled to
- memory ) press Amiga-X. If assembled to disk, leave the editor and
- run it from CLI.
- As a quick introduction to the debugger the following
- tutorial is recommended. If you have any problems please read the
- relevant section of the manual before contacting us for technical
- support.
-
- A VERY QUICK TUTORIAL
- This is a quick tutorial intended to let you see how quick
- and easy it is to edit, assemble and debug programs with DEVPAC.
- In this tutorial we are going to assemble and run a simple
- program, which contains two errors, and debug it. The program
- itself is intended to print a message.
- To run this tutorial you must be in the CLI. If you are not you
- should wait for any disk activity to stip, eject all disks, press
- (CTRL) and both Amiga keys, and insert the backup of DEVPAC disk one.
- It is convenient if we make the current directory the one where our
- source program is, with the command:
-
- cd examples (RETURN)
-
- Next load the editor/assembler, by typing:
-
- genam2 (RETURN)
-
- After a short delay the screen will show an empty window: to
- load the file you should move the mouse over the PROJECT menu and
- hold the right mouse button, and release it on LOAD. A file selector
- will then appear and the file we want is called DEMO.S. You should
- click on the name to load followed by OK.
- When the file has loaded the window will show the top lines
- of the file. If you want to have a quick look at the program you
- may press (SHIFT)-(DOWNCURSOR) or (CTRL)-C to move to the next page.
- With most shorter programs it is best to have a trial
- assembly that doesn't produce a listing or binary file to check
- the syntax of the source and show up any typing errors and so on.
- Move the mouse to the Program menu and click on Assemble.
- A dialogue box will appear, which should be left alone except
- the button near the bottom, labelled NONE, should be clicked on.
- Click on the Assemble button or press RETURN and the assembly will
- begin.
- The assembler will report an error, instruction not
- recognised, and pressing any key will return you to the editor. The
- cursor will be placed on the incorrect line and the error message
- displayed in the status line.
- The program line should be changed from MOV.L to MOVE.L so do
- this, then click on Assemble form the Program menu again. This
- time click on the Memory button, this means the program will be
- assembled into memory, instead of onto disk. This is very much
- faster and allows you to try things out immediately, which is
- exactly what we want. Clicking on the Assemble button will again
- assemble it, and after you press a key to return to the editor
- it's ready to run.
- The assembly worked this time, but don't run it yet - you will
- probably get a software error task held message from the system and
- have to reboot the machine.
- The tool for finding bugs and checking programs is a debugger,
- so click on Debug from the Program menu. The debugger is described
- more fully later, but for now we just want to run the program from the
- debugger to 'catch' any problems and find out what causes them, so
- press (CTRL)-R.
- After a brief delay the message Address Error will appear at the
- bottom of the display, with the disassembly window showing the
- current instruction:
-
- start MOVE.L dosname,a1
-
- This will cause an address error because location dosname is at
- an odd address which cannot be accessed with the MOVE.L instruction.
- There should be a hash sign before the dosname to put the address of
- dosname into the register a1. To return to the editor press (CTRL)-Q,
- to ensure that the program will be killed and press Y to terminate the
- program and the debugger. We can fix this bug in the source code.
- Press (AMIGA)-T, to go to the top of the file, then click on Find
- from the Search menu. We are going to find the errant instruction
- so enter:
-
- MOVE.L
-
- Then press Return to start the search. The first occurrence is
- the one we are looking for:
-
- start MOVE.L dosname,a1
-
- Ahah! - this is the one, so add a hash to change it to
-
- start MOVE.L #dosname,a1
-
- then assemble it again. If you click on RUN from the Program
- menu you should see the message, and pressing any key will return
- you to the editor.
- Although the program now works we shall use MONAM2, the
- debugger, to trace through the program, step by step. To do this
- click on Debug from the Program menu, and the debugger will appear
- with the message Breakpoint, showing your program.
- There are various windows, the top one displaying the machine
- registers, the second a disassembly of the program, the third some
- other memory.
- If you look at window 2, the disassembly window, you will see
- the current instruction, which in our case is:
-
- start MOVE.L #dosname,a1
-
- As the debug was specified in the source code any symbols
- will appear in the debugger.
- Let's check the area around dosname. Press (AMIGA)-3 and you
- should see the window 3's title inverted. Next press (AMIGA)-A and a
- dialogue box will appear, asking WINDOW START ADDRESS? - to this
- enter:
-
- string
-
- (it must be in lower-case) and press (RETURN). This will
- re-display window 3 at the address, showing the message in both
- hex and ASCII.
- To execute this MOVE instruction press Ctrl-Z. This will
- execute the instruction then the screen will be updated to reflect
- the new values of the program counter and register A1. If you
- press Ctrl-Z again the MOVEQ instruction will be executed and d0 will
- be modified. The next two instructions are the expansion of the
- CALLEXECOpenLibrary macro call. Use (CTRL)-z to single step the move
- to a6 instruction.
-
- Next we have:
-
- jsr _LVOOpenLiberary(a6)
-
- This is the call to the exec liberary. All calls to the AMIGAs
- operating system have the same form. We don't want to single step this
- - we know that amigaDOS works. To treat this system call as one
- instruction use (CTRL)-T
- Now single step the next (TST.L d0). D0 should be non-zero; so
- the Z flag won't be present in MONAM's register display area.
- Now you can continue to press (CTRL)-z until you get to:
-
- jsr _LVOOutput(a6)
-
- This is the call to the DOS.liberary to find our output
- handle. Use (CTRL)-T to skip over this. Use (CTRL)-Z to continue
- single stepping until we get to:
-
- jsr _LVOWrite(a6)
-
- This is the call that will actually write our string on the
- screen - lets make sure that the registers are set up correctly. d1
- should have the output handle that came back from the output call in
- d0. d2 should have the address of the message. If you look from d2 in
- the register display you will see the ASCII bytes of the string. Now
- use (CTRL)-T to skip over the Write call. To check that it worked
- press the V key, then press any other key to return to monam (being
- careful not ot activate any other windows meantime).
- Now all that is left is our de-initialisation. You can use the
- (CTRL)-Z and (CTRL)-T commands to step through it as before.
- The last instruction in the program is an RTS. Single stepping
- this will terminate Monam, for now, and return to the editor.
-
- CHAPTER 2: SCREEN EDITOR
-
- INTRODUCTION
- To enter and assemble your programs you need an editor of
- some sort and an assembler. GenAM is our editor which loads and runs
- the assembler. Genim as required giving the appearance of a full
- screen editor and a fast, full specification assembler as one program.
- It also allows you to run your assembled programs directly from
- memory without having to quit the program or do a disk access and
- to access a debugger at the press of a key. The fact that all these
- features are combined in one program means that correcting
- errors and making changes is as fast as possible without the need
- for slow disk accesses and other programs.
- This chapter details the use of the editor and how to
- assemble program - it does not detail the assembler or the
- debugger themselves, they are covered in the following chapters.
- To run GenAM, enter the command GENAM2 from the CLI. When it has
- loaded it will open an empty window, ready for you to enter and
- assemble your programs.
-
- THE EDITOR
- A text editor is a program which allows you to enter and
- alter lines of text, store them on disk, and load them back again.
- There are two types of text editors: line editors, which treat
- each line separately and can be very tricky to use, and screen
- editors, which display your text a screen at a time. The latter
- tend to be much easier to use.
- The GENAM is a screen editor which allows you to enter and edit
- text and save and load from disk, as you would expect. It also lets
- you print all or some of your text, search and replace text patterns.
- It is intuition based, which means it uses all the user friendly
- features of amiga programs that you have become familiar
- with on your computer such as windows, menus and mice. However, if
- you're a die-hard, used to the hostile world of computers before
- the advent of WIMP's, you'll be pleased to know that you can do
- practically everything you'll want to do from the keyboard without
- having to touch a mouse.
- The editor is 'RAM-based', which means that the file you are
- editing stays in memory for the whole time, so you don't have to
- wait while your disk grinds away loading different sections of the
- file as you edit. As the amiga can have so much memory, the size
- limitations often found in older computer editors don't exist with
- GenAM; if you have enough memory you can edit files of over 300k
- (though make sure your disk is large enough to cope with saving it
- if you do !).
- As all editing operations, including things like searching,
- are RAM based they act blindingly quickly. When you have typed in your
- program it is not much use if you are unable to save it to disk, so
- the editor has a comprehensive range of save and load options,
- allowing you to save all or part of the text and to load other files
- into the middle of the current one, for example.
- To get things to happen in the editor, there are various
- methods available to you. Features may be accessed in one or more
- of the following ways;
-
- Using a single key, such as a Function or cursor key:
-
- Clicking on a menu item, such as SAVE:
-
- Using a menu shortcut, by pressing the right amiga key
- (subsequently referred to as (amiga)) in conjunction with
- another such as (AMIGA)-F for Find:
-
- Using the control key (subsequently referred to as Ctrl) in
- conjunction with another, such as Ctrl-A for cursor word
- left:
-
- Clicking on the screen, such as in the window itself.
-
- The menu short cuts have been chosen to be easy and obvious
- to remember, the cursor key functions are based on those in the
- amigaBASIC editor check, while the Ctrl commands are based on those
- used in Wordstar, and many other compatible editors since.
- If at any time you get stuck, pressing the HELP key will
- bring up a comprehensive display of the keys for functions not
- visible in menus.
-
- A FEW WORDS ABOUT REQUESTERS
- The editor makes extensive use of requesters, so it is
- worth recapping how to use them, particularly for entering text.
- The editor's requesters contains string gadgets and buttons.
- String gadgets enables to enter and edit text, and are
- depicted by a box containing the text, and with a block indicating the
- cursor position. Characters may be typed in and corrected using the
- (BACKSPACE), (DEL), and cursor keys. You can clear the whole edit
- field by pressing (AMIGA)-X. Ypu can move the cursor to the beginning
- by pressing (SHIFT) and left cursor key, or to the end by (SHIFT) and
- right cursor key. If there is more than one editable text field in a
- dialog box, you can move between them by clicking near them with the
- mouse.
- Buttons may be clicked on with the mouse and cause the
- requester to go away. Usually there is a default button, shown
- by having a double border. Pressing (RETURN) on the keyboard is
- equivalent to clicking on the default button, so long as a string
- gadget is active.
- Some requesters allow only a limited range of characters
- to be typed into them - for example the Goto Line requester.
-
- THE FILE REQUESTER
- The file requester is used to select file names for the disk
- input and output facilities of the editor. In it's simplest form all
- you need is to click on the file on the cancel button. At the top of
- Requester is the drawer specification, this determines which disk and
- sub-directory is displayed and can include wildcards, for example the
- specification:
-
- df1:examples/#?.s
-
- will display all files ending in .s. If you edit this specification,
- pressing the (RETURN) key will cause the directory to be read and
- displayed in the main part of the requester. Files may be selected by
- clicking on them and pressing (RETURN) or clicking on OK. The file
- list shows sub-directories with the (dir) prefix and the scroll bar
- may be used to navigate the file list. Files mey be selected or the
- requester cancelled while the directory is still being read! When
- initially invoked, only the first fiew files will be displayed. To
- update the file listm, click on the slider on the right of the
- filename list.
- NOTE: Teh file requester uses the ARP libarary by Charlie
- Heath. If this library is not found then a simple string gadget will
- be used in it's place, in the same way as GenAm version 1. More
- details of the ARP library can be found in the ARP sub-directory on
- disk two.
-
- ENTERING TEXT AND MOVING THE CURSOR
- Having loaded GenAM, you will be presented with an empty
- window with a status line at the top and an orange block, which is
- the cursor, in the top left-hand corner.
- The status line contains information about the cursor
- position in the form of Line Column offsets as well as the number
- of bytes of memory which are free to store your text. Initially
- this is displayed as 59980, as the default text size is 60000
- bytes. You may change this default if you wish, together with
- various other options, by selecting Preferences, described later.
- The missing 20 bytes are used by the editor for internal
- information. The rest of the status line area is used for error
- messages, which will usually be accompanied with a 'display flash'
- to alert you. Any message that get printed wil be removed
- subsequently when you press a key.
- To enter text, you type on the keyboard. As you press a key
- it will be shown on the screen and the cursor will be advanced
- along the line. If you are a good typist you may be able to type
- faster than the editor can re-display the line; if so, don't
- worry, as the program will not lose the keystrokes and will catch
- up when you pause.
- At the end of each line you press the (RETURN) key (or the
- Enter key on the numeric pad) to start the next line. You can correct
- your mistakes by pressing the Backspace key, which deletes the
- character to the left of the cursor, or the Delete key, which removes
- the character the cursor is over.
- The main advantage of a computer editor as opposed to a
- normal typewriter, is its ability to edit things you typed a long
- time ago. The editor's large range of options allow complete
- freedom to move around your text at will.
-
- CURSOR KEYS
- To move the cursor around the text to correct errors or enter
- new characters, you use the cursor keys, (the arrows). If you move
- the cursor past the right-hand end of the line this won't add
- anything to your text, but it you type some text at the point the
- editor will automatically add the text to the real end of the
- line. If you type in long lines the window display will scroll
- sideways if necessary.
- If you cursor up at the top of the window the display will
- either scroll down if there is a previous line, or print the
- message Top of file in the status line. Similarly if you cursor
- down off the bottom of the window the display will either scroll
- up if there is a following line, or print the message End of file.
- For those of you used to Wordstar, the keys Ctrl-S, Ctrl-D,
- Ctrl-E and Ctrl-X work in the same way as the cursor keys.
- To move immediately to the start of the current line, press
- Ctrl (left arrow), to move to the end of the current line press
- Ctrl (right arrow).
- To move the cursor a word to the left, press Shift (left
- arrow) and to the right press Shift (right arrow). You cannot move
- a cursor past the end of a line with this. A word is defined as
- anything surrounded by a space, a tab or a start or end of line.
- The keys Ctrl-A and Ctrl-F also move the cursor left and sight on
- a word basis.
- To move the cursor a page up, you can click on the upper grey
- part of the vertical scroll bar, or press Ctrl-R or Shift (up
- arrow). To move the cursor a page down, you can click on the lower
- grey part of the scroll bar, or press Ctrl-C or Shift (down
- arrow).
- If you want to move the cursor to a specific position on the
- screen you move the mouse pointer to the required place and click
- (There is no Wordstar equivalent for this feature!)
-
- TAB KEY
- The Tab key inserts a special character (ASCII code 9) into
- your text, which on the screen looks like a number of spaces, but is
- rather different. Pressing Tab aligns the cursor onto the next
- 'multiple of 8' column, so if you press it at the start of a line
- (column 1) the cursor moves to the next multiple of 8 + 1, which
- is column 9. Tabs are very useful indeed for making items line up
- vertically and its main use in GenAM is for making instructions
- line up. When you delete a tab the line closes up as if a number
- of spaces had been removed. The advantage of tabs is that they
- only take up 1 byte of memory, bat can show on screen as many
- more, allowing you to tabulate your program neatly. You can change
- the tab size before or after loading GenAM using the Preferences
- command described shortly.
-
- BACKSPACE KEY
- The Backspace key removes the character to the left of the
- cursor. If you backspace at the very beginning of a line it will
- remove the 'invisible' carriage return and join the line to the
- end of the previous line. Backspacing when the cursor is past the
- end of the line will delete the last character on the line, unless
- the line is empty in which case it will re-position the cursor on
- the left of the screen.
-
- DEL KEY
- The Delete key removes the character under the cursor and has
- no effect if the cursor is past the end of the current line.
-
- GOTO A PARTICULAR LINE
- To move the cursor to a particular line in the text, click on
- Goto line.. from the Options menu, or press (AMIGA)-G. A requester
- will appear allowing you to enter the required line number. Press
- (RETURN) or click on OK button to go to the line or click on Cancel
- to abort the operation. After clicking on OK the cursor will move
- to the specific line, re-displaying if necessary, or give error
- End of file if the line does't' exist.
-
- GOTO TO TOP OF FILE
- To move to the top of the text, click on Goto Top from the
- Options menu, or press (AMIGA)-T. The screen will be re-drawn if
- requested.
- NOTE: (AMIGA)-upcurser goes to the previous page not to the
- top of file - this has been changed from DEVPAC 1 because some users
- found this sequence too easy to hit by mistake.
-
- GOTO END OF FILE
- To move the cursor to the start of the very last line of
- text, click on Goto Bottom, or press (AMIGA)-B
- NOTE: (AMIGA)-downcursor goes to the next page not to the
- bottom of file - this has been changed from DEVPAC 1 because some
- users found this sequence too easy to hit by mistake.
-
- QUITTING GENAM
- To leave GenAM, and remove it from memory, click on Quit
- from the Project menu, or press (AMIGA)-Q. If changes have been made
- to the text which have not been saved to disk, an alert box will
- appear asking for confirmation. Clicking on Cancel will return you to
- the editor, while clicking on OK will discard the changes and return
- you to the CLI.
-
- DELETING TEXT
-
- DELETE LINE.
- The current line can be deleted from the text by pressing
- Ctrl-Y.
-
- DELETE TO END OF LINE.
- The text from the cursor position to the end of the current
- line can be deleted by pressing Ctrl-Q. (This is equivalent to the
- Wordstar sequence Ctrl-Q Y).
-
- UNDELETE LINE
- When a line is deleted using either of the above commands it
- is preserved in an internal buffer, and can be re-inserted into
- the text by pressing Ctrl-U, or the Undo key. This can be done as
- many times as required, particularly useful for repeating similar
- lines or swapping over individual lines.
-
- DELETE ALL TEXT
- To clear out the current text, click on Clear from the Project
- menu, or press (AMIGA)-C. If you have made any changes to the text
- that have not been saved onto the disk, a confirmation is required
- and the requisite alert box will appear. Clicking on OK will
- delete the text, or Cancel will abort the operation.
-
- DISK OPERATIONS
- It is no use being able to type in text if you are unable to
- save it anywhere perminently, or load it back subsequently, so the
- editor has a comprehensive set of features to read from and write to
- disk.
-
- SAVING TEXT
- To save the text you are currently editing, click on Save As
- from the Project Menu, or press (AMIGA)-S. The File requester
- will appear, allowing you to select a suitable disk and filename.
- Clicking OK or pressing Return will then save the file onto the
- disk. If an error occurs a requester will appear showing a sutable
- error message, or an AmigaDOS error number, the exact meaning of which
- can be found in Appendix A.
- If you click on Cancel the text will not be saved. Normally
- if a file exists with the same name it will be deleted and
- replaced with the new version, but if Backups are selected from
- the Preferences options then any existing file will be renamed
- with extension .BAK (deleting any existing .BAK file) before the
- new version is saved.
-
- SAVE
- If you have already done a save as (or a load), GenAm will
- remember the name of the file and display it in the title bar of the
- window. If you want to save it without having to bother with the file
- requester. You can click on save on the Project menu, or press Shift-
- (AMIGA)-S, and it will use the old name and save it as above. If you
- try to sve without having previously specified a filename you will be
- presented with a file requester, as in save as.
-
- LOADING TEXT
- To load a new file, click on Load from the Project menu, or
- press (AMIGA)-L. If you have made any changes that have not been
- saved, a confirmation will be required. The file requester will
- appear, allowing you to specify the disk and filename. Assuming you do
- not cancel, the editor will attempt to load the file. If it will fit,
- the file is loaded into memory and the window is re-drawn. If it will
- not fit an alert box will appear warning you, and you should use
- preferances to make the edit buffer size larger, then try to load it
- again.
-
- INSERTING TEXT
- If you want to read a file from disk and insert it at the
- current position in your text click on Insert File from the File
- menu or press (AMIGA)-I. The file requester will appear and assuming
- that you do not cancel, the file will be read from the disk and
- inserted, memory permitting.
-
- CHANGE DIRECTORY
- This command lets you change the current directory that you are
- using. Simply uses the file requester to change the directory you
- wish.
-
- SEARCHING AND REPLACING TEXT
- To find a particular section of text click on Find from the
- Search menu, or press (AMIGA)-F. A dialogue box will appear, allowing
- you to enter the Find and Replace strings. If you click on Cancel,
- no action will be taken; if you click Next (or press Return) the
- search will start forwards, while clicking on Previous will start
- the search backwards.
- If you do not wish to replace, leave the Replace string empty.
- If the search was successful, the screen will be re-drawn at that
- point with the cursor positioned at the start of the string. If the
- search string could not be found, the message Not Found will appear in
- the status area and the cursor will remain unmoved. By default the
- search is always case-independant, so for example if you enter the
- search string as test you could find the words TEST, Test or test.
- If you click on the Upper & Lower case Different button the search
- will be case dependant.
- To find the next occurrence of the string click on Find Next
- from the Search menu, or press (AMIGA)-N. The search starts at the
- position just before the cursor.
- To search for the previous occurrence of the string click on
- Find Previous from the Search menu, or press (AMIGA)-P.
- Having found an occurrence of the required text, it can be
- replaced with the Replace string by clicking on Replace from the
- Search menu, or pressing (AMIGA)-R. Having replaced it, the editor
- will then search for the next occurrence.
- If you wish to replace every occurrence of the find string
- with the replace string from the cursor position onwards, click on
- Replace All from the Search menu. During the global replace the
- ESC key can be used to abort and the status area will show how
- many replacements were made. There is deliberately no keyboard
- equivalent for this to prevent it being chosen accidentally.
- To search and replace tab characters just press (TAB) when
- typing in the dialog box. Other control characters may be searched for
- by typing them in directly ((CTRL)-G for example). However do not use
- this for CR((CTRL)-M) and LF((CTRL)-J) characters.
-
- BLOCK COMMANDS
- A Block is a marked section of text which may be copied to
- another section, deleted, printed or saved onto disk. The function
- keys are used to control blocks.
- Block markers remain during all editing commands, moving where
- necessary. and are only reset by the commands New, Delete Block, and
- Load.
-
- MARKING A BLOCK
- The start of a block is marked by moving the cursor to the
- required place and pressing key F1. The end of a block is marked
- by moving the cursor and pressing key F2. The start and end of the
- block do not have to be marked in a specific order - if it is more
- convenient you may mark the end of the block first.
- A marked block is highlighted by showing the text in reverse.
- While you are editing a line that is within a block this
- highlighting will not be shown but will be re-displayed when you
- leave that line or choose a command.
-
- SAVING A BLOCK
- Once a block has been marked, it can be saved by pressing key
- F3. If no block is marked, the message What blocks! will appear.
- If the start of the block is textually after its end the message
- Invalid block! will appear. Both errors abort the command.
- Assuming a valid block has been marked, the file requester
- will appear, allowing you to select a suitable disk and
- filename. If you save the block with a name that already exists
- the old version will be overwritten - no backups are made with
- this command.
-
- COPYING A BLOCK
- A marked block may be copied, memory permitting, to another
- part of the text by moving the cursor to where you want the block
- copied and pressing key F4. If you try to copy a block into a part
- of itself, the message Invalid block will appear and the copy will
- be aborted.
-
- DELETING A BLOCK
- A marked block may be deleted from the text by pressing
- Shift-F5. The shift key is deliberately required to prevent it
- being used accidentally. A deleted block is remembered, memory
- permitting, in the block buffer, for later use.
- There are two key sequences with this command for
- compatibility with both DEVPAC version 2 and DEVPAC version 1.
-
- COPY BLOCK TO BLOCK BUFFER
- The current marked block may be copied to the block buffer,
- memory permitting, by pressing Shift-F4. This can be very useful
- for moving blocks of text between different files by loading the
- first, marking the block, copying it to the block buffer then
- loading the other file and pasting the block buffer into it.
-
- PASTING A BLOCK
- A block in the block buffer may be pasted at the current
- cursor position by pressing F5.
- The block buffer will be lost if the edit buffer size is
- changed or an assembly occurs.
-
- PRINTING A BLOCK
- A marked block may be sent to the printer by printing on
- Print Block from the File menu, or by pressing (AMIGA)-W. A requester
- will appear asking for the name of the printer, which defaults to
- PRT:, and clickingon ok will print the block. Of course the name can
- be any valid AmigaDOS device, so you could "print" the block to disk
- if required. It is differant to Save Block in that tabs are expanded
- to spaces.
- If you try to print when there is no block marked, the whole
- file will be printed.
-
- MISCELLANEOUS COMMANDS
-
- HELP SCREEN
- The key equivalents for the commands not found in menus can
- be seen by pressing the HELP key, or (AMIGA)-H. A dialogue box will
- appear showing the function key uses, the version of GenAm that is
- running and the total free memory in the system.
-
- PREFERENCES
- Selecting Preferences.. from the Options menu will produce a
- dialogue box allowing you to change several editor settings.
-
- TABS
- By default, the tab setting is 8, but this may be changed to
- any value from 2 to 16.
-
- TEXT BUFFER SIZE
- By default the text buffer size is 60000 bytes, but this can
- be changed from 4000 to 999000 bytes. This determines the largest
- file size that can be loaded and edited, Care should be taken to
- leave sufficient room in memory for assembly or running MonAm.
- Changing the editor work-space size will cause any text you are
- currently editing to be lost, so a confirmation is required if it
- has not been saved.
-
- BACKUPS
- By default the editor doesn't make backups of programs when
- you save them, but this can be turned on by clicking on the Yes
- radio button.
-
- AUTO INDENTING
- It can be particularly useful when editing programs to indent
- subsequent lines from the left, so the editor supports an auto-
- indent mode. When active, an indent is added to the start of each
- new line created when you press RETURN. The contents of the indent
- of the new line is taken from the white space (i.e. tabs and/or
- spaces) at the start of the previous line.
-
- END OF LINE
- By default (i.e. when Stop is selected) when you press cursor
- left at the beginning of a line or cursor right at the end of line the
- cursor does not move. Changing this item to wrap causes the cursor to
- move to the previous line if you press cursor left at the beginning
- and to the next line if you press curser left at the beginning and the
- next line if you presscursor right at the end. The best way to find
- out which you prefer is to try using both settings.
-
- LOAD MONAM
- By default a copy of MonAM is loaded during the editor
- initialisation, allowing it to be accessed at the press of a key.
- Should this not be required it can be disabled with this option.
- This will save around 24k of memory. The new value of this option
- will only have an effect if you save the preferences and re-
- execute the editor.
-
- AUTOSIZE WINDOW
- By default, Genam will not use the entire screen display, but if
- this is selected then it will make it's initial window as large as
- possible.
-
- SAVING PREFERENCES
- If you click on the Cancel button any changes you make will
- be ignored. If you click on the OK button the changes specific
- will remain in force until you quit the editor. If you would like
- the configuration made permanent then click on the Save button,
- which will create the file GENST2.INF on your disk. Next time you
- run GenST the configuration will be read from that file in the current
- directory. In addition to saving the editor configuration the
- current setting from the Assembly Options dialogue box are also saved.
- If the .INF file is not found in the current directory when the editor
- is loaded, the c: directory is also searched. This allows a global
- settings as well as specific local ones.
-
- ASSEMBLING & RUNNING PROGRAMS
- All assembly and run options can be found on the Program menu
-
- ASSEMBLY
- To assemble the program you are currently editing click on
- Assemble from the Program menu, or press (AMIGA)-A. The meaning of the
- various options, together with the assembly process itself is
- detailed in the next chapter. The only option covered here is the
- Output option.
- GenAM can assemble to disk, to memory, or nowhere -
- assembling to nowhere is ideal for syntax checking while assembly
- to memory is much faster than to disk and good for trying things
- out quickly.
- If you assemble to disk and you haven't saved your program source
- code yet the file will be based on the name NONAME.
- After you click on Assembly or press RETURN the assembly
- process will start, describe more fully in the next chapter. At
- the end of the assembly the program will wait for a key press,
- allowing you to read any messages produced, before returning you
- to the editor. If there were any errors the editor will go to the
- first erroneous line and display the error message in the status
- bar. Subsequent errors (and warnings) may be investigated by
- pressing (AMIGA)-J.
-
- RUNNING PROGRAMS
- If you click on Run or press (AMIGA)-X (eXecute) you can then run
- a program previously assembled into memory. When your program
- finishes it will return you to the editor. If the assembly didn't
- complete normally for any reason then it is not possible to run
- the program.
- If your program crashes badly you may never return to the
- editor, so if in doubt save your source code before using this, or
- the following command.
- If only non-fatal errors occurred during assembly (e.g.
- undefined symbols) you will still be permitted to run your
- program, at your own risk.
-
- DEBUG
- If you wish to debug a program previously assembled to memory
- click on Debug form the Program menu, or press (AMIGA)-D. This will
- invoke MonAM to debug your program, including any debugging
- information specified. Pressing Ctrl-C from MonAM will terminate
- the debugger.
- If the Load MonAM option is disabled this option is not
- available and the menu is disabled.
-
- MONAM
- Clicking on MonAM from the Program menu, or pressing (AMIGA)-M,
- will invoke MonAM in a similar way to if it was invoked by typing it's
- name in CLI, but instantly, as it is already in memory. You will
- return to the editor on termination of the debugger.
- If the Load MonAM option is disabled this option is not
- available and the menu is disabled.
-
- JUMP TO ERROR
- During an assembly any warnings or errors that occur are
- remembered, and can be recalled from the editor. Clicking on Jump
- to Error from the Program menu, or pressing (AMIGA)-J will move the
- cursor to the next line in your program which has an error, and
- display the message in the status line of the window. You can
- step to the next one by pressing (AMIGA)-J again, and so on, letting
- you correct errors quickly and easily. If there are no further
- errors when you select this option the message No more errors will
- appear, or if there are no errors at all the message What errors!
- will appear.
-
- THE EDITOR WINDOW
- The window used by the editor works like the most other Amiga
- windows, so you can move it around by using the drag gadget on the top
- of it, you can change it's size by dragging on the size gadget and
- control it's position relative to the other windows by using the front
- and back gadgets. Clicking on the close gadget is equivelant to
- choosing Quit fron the project menu. Like all intuition windows, it
- has to be active for you to be able get at it's menu items. If you
- have a larger than normal screen size (eg. a european PAL system which
- has 256 vertical lines) you can re-size the window to be the full size
- of your screen.
- When GenAm is busy doing a disk access or assembly the cursor
- changes to an hourglass and all menu items are made grey.
- NOTE: When using GenAm (And MonAm) on PAL machines with
- external RAM, you may sometimes get two mouse pointers; one will be
- the normal intuition pointer, the other will be the custom pointer
- allocated with the program you are using. Do not be alarmed - this
- seems to be a harmless bug in intuition.
-
- SYSTEM REQUESTERS
- When a system requester appears from the editor (eg. File not
- found), pressing any key is equivelant to clicking on cancel.
-
- CHAPTER 3: MACRO ASSEMBLER
-
- INTRODUCTION
- GenAM is a powerful, fast, full specification assembler,
- available instantly from within the editor or as a stand alone
- program. It converts the text typed or loaded into the editor,
- optionally together with the files read from the disk, into a
- binary file suitable for immediate execution or linking, or into a
- memory image for immediate execution from the editor.
-
- INVOKING THE ASSEMBLER
-
- FROM THE EDITOR
- The assembler is invoked from the editor by clicking on
- Assemble from the Program menu, or by pressing (AMIGA)-A. A dialogue
- box will appear which looks like this (almost);
-
- |------------------------------------------------|
- | Program type Executable Linkable |
- | Symbols case Dependant Independant |
- | Debug info None Normal Exports |
- | List None Screen Printer Disk |
- | Assembly Fast Slower |
- | Output to None Memory |
- | ______________________________________ |
- | Disk |______________________________________| |
- | Assembly options |
- | Cancel Assemble |
- | _______________________________________________|
-
- PROGRAM TYPE This lets you select between executable or
- linkable format output. The differences between these are detailed
- later.
-
- SYMBOLS CASE This lets you select whether labels are case
- dependant or not. If case Dependant is selected then Test and test
- would be different labels, if the case Independant is selected
- then they would be the same.
-
- DEBUG INFO If you wish to debug your program using your
- original symbols you can select Normal or Extended debug modes.
-
- LIST selecting Printer will divert the assembly listing to the
- PRT: device, or selecting Disk will send the listing to a
- file based on the source filename, but with the extension .LST.
-
- ASSEMBLER Normally this option should be left as fast selected,
- but if the assembler runs out of memory select slower. Selecting
- Slower forces the assembler to use little memory as possible thus
- slowing down things like reading include files.
-
- OUTPUT TO This lets you select where the output file is to be
- created. None means it is 'thrown away', ideal for syntax checking
- a program; Memory means it is assemble into a buffer allowing it
- to be run or debugged instantly form the editor without having to
- create a disk file: Disk means a file will be created. The
- selection of the name of this file can be left to the assembler,
- using rules described shortly.
- The first two options may be specified in the source file
- using the OPT directive.
- Having selected your required options you should click on the
- Assemble button (or press Return) to start the assembly. At the
- end of assembly you should press any key to return to the editor.
- If any errors occurred the cursor will be positioned on the first
- offending line.
-
- STAND ALONE ASSEMBLER
-
- COMMAND LINE FORMAT
- The assembler, Genim2, may by invoked directly from the CLI.
- The command line should be the form:
-
- GenIm2 mainfile <-options> [-options]
-
- The mainfile should be the name of the file requiring
- assembly and if no extension is specified defaults to ,S. Options
- should follow this donated by a - sign then an alphabetical
- character. Allowed options are shown below together with
- equivalent OPT directives :
-
- B no binary file should be created
-
- C case insensitive labels (OPT C-)
-
- D debug (OPT D+)
-
- I specify include directory (follow immediatly with path)
-
- L linkable code (OPT L+)
-
- M use slow(low memory) assembly mode. See above. Not the
- same as OPT m+
-
- O specify output filename (follows immediately after O)
-
- P specify listing filename (should follow immediately
- after P) defaults to source filename with extension .LST
-
- Q pause for key press after assembly
-
- T specifies the tab setting for listing. For example -T10
- uses a tab setting of 10.
-
- X used when generating linkable code to export only the
- exported (XDEFed) symbols (OPT X+)
-
- NOTE: The options used by GenIm2 are rather differant to those
- used in DEVPAC version 1 but the same as DEVPAC version 2.
-
- The default is to create an executable binary file with the
- name based on the source file and output file type, no listing,
- with no case sensitive labels. For example,
-
- genim2 test -b
-
- assembles test.s with no binary output file
-
- genim2 test -oram:test -p -iminc/
-
- assembles test.s into a binary file ram:test.prg and a listing file
- to test.lst, with an include directory of myinc.
-
- genim2 test -ldppprt:
-
- assembles test.s into linkable code with debug and a listing
- to the printer as set using the Amiga Preferances tool.
-
- OUTPUT FILENAME
- GenAM has certain rules regarding the calculation of the
- output filename, using a combination of that specified at assembly
- time (either in the Disk: string gadget in the requester) or
- using the -O option on the command line) and the Output directive:
- If an output filename is explicitly given at assembly time then:
- name = explicit filename
-
- else:
- if the Output directive has not been used then
- name = source filename without an extension or .O
- else if the Output directive specifies an extension then
- name = source filename + extension in Output
- else
- name = name in Output
-
- ASSEMBLY PROCESS
- GenAM is a two-pass assembler; during the first pass it scans
- all the text in memory and from disk if required, building up a
- symbol table. If syntax errors are found on the first pass
- assembly these will be reported and assembly will stop at the end
- of the first pass, otherwise, during the second pass the
- instructions are converted into bytes, a listing may be produced
- if required and a binary file can be created on the disk. During
- the second pass any further errors and warnings will be shown,
- together with a full listing and symbol table if required.
- During assembly, any screen output can be paused by holding down
- the right mouse button or, when using the stand alone assembler, by
- pressing any key (pressing (RETURN) will resume it). Assembly may
- be aborted by pressing Ctrl-C, although doing so will make any
- binary file being created invalid as it will be incomplete and
- should not be executed.
-
- ASSEMBLY TO MEMORY
- To reduce development time GenAM can assemble programs to
- memory, allowing immediate execution or debugging from the editor.
- A program running from memory is just like any other normal
- AmigaDOS program and should terminate using an RTS instruction with
- the stack as the program was entered.
- Programs should be careful if they self-modify as a re-executed
- program will be in its original state. The state is left as when the
- program was previously executed.
- The current assembly options can be made the default on re-
- loading the editor if Save Preferences is used.
-
- BINARY FILE TYPES
- There are two types of binary files which may be produced by
- GenAM, for different types of applications. They are distinguished
- by the extension on the filename:
- If there is no extension then this is a directly executable file,
- or if the extension is .o or .obj then this is an AmigaDOS linkable
- file.
- Actually there are two sorts of executable files; those that are
- designed to be run from the CLI and those that are designed to be run
- from workbench. The differance is in the code that is part of the
- program; the assembler cannot tell the differance. This is described
- later.
- .o files cannot be run immediatly, but have to be read into a
- linker, usually with other sections, and are known as linkable object
- modules.
-
- TYPES OF CODE
- Unlike most 8-bit operating systems, but like most 16-bit
- systems, an executable program under AmigaDOS will not be loaded at
- a particular address but, instead, be loaded at an address
- depending on the exact free memory configuration at that time.
- To get around the problem of absolute addressing the ST file
- format includes relocation information allowing GEMDOS to relocate
- the program after it has loaded it but before running it. For
- example the following program segment:
-
- move.l #string, a0
- .
- .
- .
- string dc.b 'Press any key',0
-
- places the absolute address of string into a register, even though
- at assembly time the real address of string cannot possibly be
- known. Generally the programmer may treat addresses as absolute
- even though the real addresses will not be known to him, while the
- assembler (or linker) will look after the necessary relocation
- information.
- NOTE: For certain programs, normally games or cross machine
- development an absolute address may be required, for this reason
- the ORG directive is supported.
-
- The syntax of the assembler will now be described.
-
- ASSEMBLER STATEMENT FORMAT
- Each line that is to be processed by the assembler should
- have the following format;
-
- Label Mnemonic Operand(s) Comment
- Start move.l d0,(a0)+ store the result
-
- Exceptions to this are comment lines, which are lines
- starting with an asterisk or semi-colon, and blank lines, which
- are ignored. Each field has to be separated from the others by
- white space - any number or mixture of space and tab characters.
-
- LABEL FIELD
- The label should normally start at line 1, but if a label is
- required to start at another position then it should be followed
- immediately by a colon (:). Labels are allowed on all
- instructions, but are prohibited on some assembler directives, and
- absolutely required on others. A label may start with the
- characters A-Z, a-z, or underline (_), and may continue with a
- similar set together with the addition of the digits 0-9 and the
- period (.).
- Labels starting with a period are local labels, described
- later. Sequances of digits terminated by a $ are also labels. Macro
- names and register equate symbols may not have periods in them,
- though macro names may start with a period. By default the first 127
- characters of labels are significant, though this can be reduced if
- required. Labels should not be the same as register names, or the
- reserved words SR, CCR or USP.
- By default labels are case-sensitive though this may be changed.
-
- Some example legal labels are ;
-
- test, Test, TEST, _test, _test.end, test5, _5test
-
- Some illegal labels are;
-
- 5test, _&e, test>,
-
- There are certain reserved symbols in GenST, denoted by
- starting with two underline characters. These are __LK, __RS and
- __G2.
-
- MNEMONIC FIELDS
- The mnemonic field comes after the label field and can
- consist of 68000 assembler instructions, assembly directives or
- macro calls. Some instructions and directives allow a size
- specifier, separated from the mnemonic by a period. Allowed sizes
- are .B for byte, .W for word, .L for long and .S for short. Which
- size specifiers are allowed in each case depends on the particular
- instruction or directive. GenAM is case-sensitive to mnemonic and
- directive names, so Move is the same as move and the same as mOvE,
- for example.
-
- OPERAND FIELD
- For those instructions or directives which require operands,
- this field contains one or more parameters, separated by commas.
- GenST is case-sensitive regarding register names so they may be in
- either or mixed case.
-
- COMMENT FIELD
- Any white space not within quotes found after the expected
- operand(s) is treated as a delimiter before the start of the
- comment, which will be ignored by the assembler.
-
- EXAMPLES OF VALID LINES
-
- move.l d0,(a0)+ comment is here
-
- loop TST.W d0
-
- lonely.label
-
- rts
-
- * this is a complete line of comment
-
- ; and so is this
-
- indented: link A6,#-10 make room
-
- a_string: dc.b 'spaces allowed in quotes' a string
-
- EXPRESSIONS
- GenAm allows complex expressions and supports full operator
- precedence, parenthesis and logical operators.
- Expressions are in two types -absolute and relative - and the
- distinction is important. Absolute expressions are constant values
- which are known at assembly time. Relative expressions are program
- addresses which are not known at assembly-time as the AmigaDOS
- loader can put the program where it likes in memory. Some
- instructions and directives place restrictions on which types are
- allowed and some operators cannot be used with certain type-
- combinations.
-
- OPERATORS
- The operators available, in decreasing order of precedence, are:
- monadic minus (-) and plus (+)
- bitwise not (~)
- shift left (<<) and shift right (>>)
- bitwise And (&), Or (!), and Xor (^)
- multiply (*) and divide (/)
- addition (+) and subtraction (-)
- equality (=), less than (<), greater than (>)
-
- The comparison operators are signed and return 0 if false or
- -1 ($FFFFFFFF) if true. The shift operators take the left hand
- operand and shift it the number of bits in the right hand operand
- and vacated bits are filled with zeros.
-
- This precedence can be overridden by the parentheses ( and ).
- With operators of equal precedence, expressions are evaluated from
- left-to-right. Spaces in expressions (other than those within
- quotes as ASCII constants) are not allowed as they are taken as
- the separator to the comment.
-
- All expression evaluation is done using 32-bit signed-integer
- arithmetic, with no checking of overflow.
-
- NUMBERS
- Absolute numbers may be in various forms;
-
- decimal constants, e.g. 1029
- hexadecimal constants, e.g. $12f
- octal constants, e.g. @730
- binary constants, e.g. %1100010
- character constants, e.g. 'X'
-
- $ is used to denote hex numbers, % for binary, @ for octal
- and single ' or double quotes " for character constants.
-
- CHARACTER CONSTANTS
- Whichever quote is used to mark the start of a string must
- also be used to denote its end and quotes themselves may be used
- in strings delimited with the same quote character by having it
- occur twice. Character constants can be upto 4 characters in
- length and evaluate to right-justified longs with null-padding if
- required. For example, her are some character constants and their
- ASCII and hex values:
-
- "Q" Q $00000051
- "hi" hi $00006869
- "Test" test $54657374
- "it's" it's $6974277C
- 'it''s' it's $6974277C
-
- Strings used in DC.B statements follow slightly different
- justification rules, detailed with the directive later.
-
- Symbols used in expressions will be either relative or
- absolute, depending on how they were defined. Labels within the
- source will be relative, while those defined using the EQU
- directive will be the same type as the expression to which they
- are equated.
- The use of an asterisk (*) denotes the value of the program
- counter at the start of the instruction or directive and is always
- a relative quantity.
-
- ALLOWED TYPE COMBINATIONS
- The table below summarises for each operator the results of
- the various type combinations of parameter an d which combinations
- are not allowed. An R denotes a Relative result, an A denotes
- absolute and a * denotes that the combination is not allowed and
- will produce an error message if attempted.
-
- A op A A op R R op A R op R
- Shift operators A * * *
- Bitwise operators A * * *
- Multiply A * * *
- Divide A * * *
- Add A R R *
- Subtract A * R A
- Comparisons A * * A
-
- ADDRESSING MODES
- The available addressing modes are shown in the table below.
- Please note that GenST is case-insensitive when scanning
- addressing modes, so D0 and a3 are both valid registers.
-
- FORM MEANING EXAMPLE
- Dn data register direct D3
- An address register direct A5
- (An) address register indirect (A1)
- (An)+ address reg indirect + post-increment. (A5)+
- -(An) address reg indirect + pre-increment. -(A0)
- d(An) address reg indirect with displacement 20(A7)
- d(An,Rn.s)address register indirect with index 4(A6,D4.L)
- d.W absolute short address $0410.W
- d.L absolute long address $12000.L
- d(PC) program counter relative with offset NEXT(PC)
- d(PC,Rn.s)program counter relative with index NEXT(PC,A2.W)
- #d immediate data #26
-
- n denotes register number from 0 to 7
- d denotes a number
- R denotes index register, either A or D
- s denotes size, either W or L, when omitted defaults to W
-
- When using address register indirect with index the displacement
- may be omitted, for example
-
- move.l (a3,d2.l),d0
-
- will assemble to the same as
-
- move.l 0(a3,d2.l),d0
-
- SPECIAL ADDRESSING MODES
-
- CCR condition code register
- SR status register
- USP user stack pointer
-
- In addition to the above, SP can be used in place of A7 in any
- addressing mode, e.g. 4(SP,D3.W)
- The data and address registers can also be denoted by use of
- the reserved symbols R0 through R15. R0 to R7 are equivalent to D0
- to D7, R8 to R15 are equivalent to A0 to A7. This is included for
- compatibility with other assemblers.
-
- LOCAL LABELS
- GenAm supports local labels, that is labels which are local
- to a particular area of the source code. These are denoted by
- starting with a period and are attached to the last non-local
- label, for example;
-
- lenl move.l 4(sp),a0
- .loop tst.b (a0)+
- bne.s .loop
- rts
- len2 move.l 4(sp),a0
- .loop tst.b -(a0)
- bne.s .loop
- rts
-
- There are two labels called .loop in this code segment but the
- first is attached to lenl, the second to len2.
- If you wish to use global labels starting with a dot you may use
- OPT U+ to allow this and make the underline character introduce local
- labels.
- The local labels .W and .L are not allowed to avoid confusion with
- the absolute addressing syntax.
-
- AMIGA MACRO ASSEMBLER LOCAL LABELS
- You may also use strings of decimal digits terminated by the $
- sign as local labels. This facility has been provided for
- compatability with other assemblers; we reccomend the use of form
- shown above as this makes programs much more readable.
-
- SYMBOLS AND PERIODS
- Symbols which include the period character can cause problems
- with GenAm due to absolute short addressing.
- The Motorola standard way of denoting absolute short addresses
- causes problems as periods are considered to be part of a label,
- best illustrated by an example:
-
- move.l vector.w,d0
-
- where vector is an absolute value, such as a system variable. This
- would generate an undefined label error, as the label would be
- scanned as vector.w. To get around this, the expression, in this
- case a symbol, may be enclosed in brackets, e.g.
-
- move.l (vector).w,d0
-
- though the period mat still be used after numeric expressions, e.g.
-
- move.l $4.w,d0
-
- NOTE: GenAm version 1 also supported the use of \ instead of a
- period to denote short word addressing and this is still supported
- in this version, but this is not recommended due to the potential
- for \W and \L to be mistaken for macro parameters.
-
- INSTRUCTION SET
-
- WORD ALIGNMENT
- All instructions with the exception of DC.B and DS.B are
- always assembled on a word boundary. Should you require a DC.B
- explicitly on a word boundary, the EVEN directive should be used
- before it. Although all instructions that require it are word-
- aligned, labels with nothing following them are not word aligned
- and can have odd values. This is best illustrated by an example;
-
- nop this is always word aligned
- dc.b 'odd'
- start
- tst.l (a0)+
- bne.s start
-
- The above code would not produce the required result as start
- would have an odd value. To help in finding such an instructions
- the assembler will produce an error if it finds an odd destination
- in a BSR or BRA operand. Note that such checks are not made on any
- other instructions, so it is recommended that you precede such
- labels with EVEN directives if you require them to be word-
- aligned. A common error is deliberately not to do this, as you
- know the preceding string is an even number of bytes long. All
- will be well until the day you change the string...
-
- INSTRUCTION SET EXTENSIONS
- The complete 68000 instruction set is supported and certain
- shorthands are automatically accepted, detailed below. A complete
- description of the instruction set including syntax and addressing
- modes can be found in any 68000 reference guide or in the supplied
- pocket guide.
-
- CONDITION CODE
- The altenate condition codes HS and LO are supported in Bcc, DBcc
- and Scc instructions, equivalent to CC and CS, respectively.
-
- BRANCH INSTRUCTIONS
- To force a short branch use Bcc.B or Bcc.S, to force a word
- branch use Bcc.W or to leave the optimiser use Bcc. Bcc.L is
- supported for compatibility with GenAm 1 with a warning as it is,
- strictly speaking, a 68020 instruction. A BRA.S to the
- immediately following instruction is not allowed and is converted,
- with a warning, to a NOP. A BSR.S to the immediately following
- instruction is not allowed and will produce an error.
-
- BTST INSTRUCTION
- BTST is unique among bit-test instructions in supporting PC-
- relative addressing modes.
-
- CLR INSTRUCTION
- CLR An is not allowed, use SUB.L An,An instead (though note
- that the flags are not affected).
-
- CMP INSTRUCTION
- If the source is immediate then CMPI is used, else if the
- destination is an address register then CMPA is used, else if both
- addressing modes are post-incremented then CMPM is used.
-
- DBcc INSTRUCTION
- DBRA is accepted as an equivalent to DBF.
-
- ILLEGAL INSTRUCTION
- This generates the op-cope word $4AFC.
-
- LINK INSTRUCTION
- If the displacement is positive or not even a warning is given.
-
- MOVE FROM CCR INSTRUCTION
- This is a 68010 and upwards instruction, converted with a
- warning to MOVE from SR.
-
- MOVEQ INSTRUCTION
- If the data is in the range 128-255 inclusive a warning will
- be given. It may be disabled by specifying a long size on the
- instruction.
-
- ASSEMBLER DIRECTIVES
- Certain pseudo-mnemonics are recognised by GenIm. These
- assembler directives, as they are called, are not (normally)
- decoded into opcodes, but instead direct the assembler time. These
- actions have the effect of changing the object code produced, or
- the format of the listing. Directives are scanned exactly like
- executable instructions and some may be preceded by a label (for
- some it is obligatory) and may be followed by a comment. If you
- put a label on a directive for which it is not relevant, the
- result will be undefined but will usually result in the label
- being ignored.
- Each directive will now be described in turn. Please note
- that the case of a directive name is not important, though they
- generally are shown in upper case. The use of angled brackets ( <> )
- in descriptions denote optional items, ellipses ( ... )
- denote repeated items.
-
- ASSEMBLY CONTROL
-
- END
- This directive signals that no more text is to be examined on
- the current pass of the assembler. It is not obligatory.
-
- INCLUDE filename
- This directive will cause source code to be taken from a file
- on disk and assembled exactly as though it were present in the
- text. The directive must be followed by a filename in normal
- AmigaDOS format.
- If the filename has a space in it the name should be enclosed
- in single or double quotes. A drive specifier, directory and
- extension may be included as required, e.g.
-
- include b:constants/header.s
-
- Include directives may be nested as deeply as memory allows
- and if any error occurs when trying to open the file or read it,
- assembly will be aborted with a fatal error.
- If no drive or path name is specified, that of the main
- source file will be used when trying to open the file.
-
- NOTE: The more memory the better, GenAm will read the whole of the
- file in one go if it can and not bother to re-read the file during
- pass 2.
-
- INCDIR "directory"<,"directory" etc.>
- This directive specifies a list of directories that the include
- directive should search in order to find each file. GenIm will append
- each string onto the front of that given in the include directive. This
- directive must appear before any include directives.
-
- INCBIN filename
- This takes a given binary file and includes it, verbatim,
- into the output file. Suggested uses include screen data, sprite
- date and ASCII files.
- The included data is forced to an even boundary and a single null
- character is appended if the file is an odd number of bytes in length.
-
- OPT option <,option>...
- This allows control over various options within GenAm and
- each one is denoted by a single character normally followed by a +
- or - sign. Multiple options may be specified, separated by commas.
- The allowed options are:
-
- OPTION A - AUTOMATIC PC MODE ADDRESSING
- If OPT A+ is specified then GenAm will use PC mode addressing
- where possible. For example:
-
- move.l int_in,d0
-
- will automatically be transformed into
-
- move.l int_in(pc),d0
-
- when assembled.
-
- Use of this option can significally reduce program size and
- running time without a lot of extra typing. Please note however thit
- it does not guarentee that the code generated will be position
- independant.
- If you need to over-ride the automatic use of PC mode then use
- the form (expression).l in a similar manner to that of short word
- addressing as described above under labels and periods.
- So the example above could be forced to use absolutre addressing
- by using the following:
-
- move.l (int_in).l,d0
-
- The default is A- when no such transformations are performed.
-
- OPTION C - CASE SENSITIVITY AND SIGNIFICANCE.
- By default, GenAm is sensitive to label case and labels are
- significant to 127 characters. This can be overridden , using C-
- for case-sensitivity or C+ for case-insensitivity. The significan
- ce may be specified by specifying a decimal number between the C
- and the sign, for example C16+ denotes case insensitive labels
- with 16 character significance. This option may be used at any
- time in a program but normally only makes sense at the very
- beginning of a source file.
-
- OPTION D - DEBUGGING INFORMATION
- The AmigaDOS binary file format supports the inclusion of a
- symbol hunk, which may be read by debuggers such as
- MONAm and can be extremely useful when debugging programs. By
- default this is switched off but it may be activated with D+ and
- de-activated with D-. Normally all the relative symbols are included
- in the file, but if OPT X+ is used in linkable mode then only the
- exported (XDEF) symbols will be included.
-
- OPTION L - LINKER MODE.
- The default for GenAM is to produce executable code but L+
- will make it produce AmigaDOS linkable code, or L- will make it
- revert to executable. This directive must be the very first line, in
- the first text file.
-
- OPTION M - MACRO EXPANSIONS.
- When an assembly listing is produced, macro calls are shown
- in the same form as in the source. If you wish the instructions
- within macros to be listed, use M+, while M- will disable the
- option. You can use this directive as often as required. M- is the
- default.
-
- OPTION O - OPTIMISING.
- GenAM is capable of optimising certain statements to faster
- and smaller versions. By default all optimising is off but each
- type can be abled and disabled as required. This option has
- several forms:
-
- OPT O1+ will optimise backward branches to short if within
- range, can be disabled with O1-.
-
- OPT O2+ will optimise address register indirect with
- displacement addressing modes to addresss register
- indirect, if the displacemant evalues to zero, and
- can be disabled with O2-. For example,
-
- move.l next(a0),d3
-
- will be optimised to
-
- move.l (a0),d3
-
- If the value of next is zero.
-
- OPT O+ will turn all optimising on.
-
- OPT O- will turn all optimising off.
-
- OPT O1-, OPT O2- will disable the relevant optimisation.
-
- OPT OW- will disable the warning messages generated by each
- optimisation, OW+ will enable them.
-
- If any optimising has been done during an assembly the number
- of optimisations made and bytes saved will be shown at the end of
- assembly.
-
- OPTION P - POSITION INDEPENDANT CHECKS.
- With this enabled with P+ GenAM will check that all code
- generated is position-independant, generating errors on any lines
- which require relocation. It can be disabled with P- and defaults
- to off.
-
- OPTION S - SYMBOL TABLE
- When a listing is turned on a symbol table will be produced
- at the end. If you wish to change this S- will disable it, while
- S+ will re-enable it. If you use this directive ore than once the
- last one will be taken into account.
-
- OPTION T - TYPE CHECKING.
- GenST can often spot programming errors as it checks the
- types of certain expressions. For some applications or styles of
- programming this can be more of a hindrance than a help. So T-
- will turn checks off. T+ turning them back on. For example the
- program segment
-
- main bsr initialise
- lea main(a6),a0
- move.l (main).w,a0
-
- will normally produce an error as main is a relative
- expression where as the assembler expects an absolute expression
- in both cases. However if this code is designed to run on another
- 68000 machine this may be perfectly valid, so the type checking
- should be disabled.
-
- OPTION U - UNDERLINES FOR LOCAL LABELS
- Option U+ changes the character that introduces local tables to
- be underline (_) rather than dat (.). Usa this if you need to use
- labels beginning with dot for non-local labels.
-
- OPTION W - WARNINGS
- If you wish to disable the warnings that GenST can produce,
- you can do so with W-. To re-enable them use W+. This directive
- can be used as often as required.
-
- OPTION X - EXPORTDEBUG
- This is a special version of option D which only outputs the
- exported (XDEFed) symbols when producing linkable code. See the D
- option above.
-
- OPTION SUMMARY
- The defaults are shown in brackets after each options
- description;
-
- A automatic PC mode addressing
- C case-sensitivity and significance (C127+)
- D include debugging info, (D-)
- L- produce executable code (default)
- L+ produce GST linkable code
- M expand macros enlisting (M+)
- O optimising control (O-)
- P position independant code checks (P-)
- S symbol table listing
- T type checking (T+)
- W warning control (W+)
- X export debug (X-)
-
- For example - opt m+,s+,w-
-
- will turn macro expansion on, enable the symbol table list and
- turn warnings off.
-
- <label> EVEN
- This directive will force the program counter to be even,
- i.e. word aligned. As GenAM automatically word-aligns all
- instructions (except DC.Bs and DS.Bs). It should not be required
- very often but can be useful for ensuring buffers and strings are
- word-aligned when required
-
- CNOP offset,alignment
- This directive will align the program counter using the given
- offset and alignment. An alignment of 2 means word-aligned, an
- alignment of 4 means long-word-aligned and so on. The alignment is
- relative to the start of the current section. For example,
-
- cnop 1,4
-
- aligns the program counter a byte past the next long-word
- boundary.
-
- Some parts of the Amiga operating system require certain items to
- be longword aligned and this can be achieved with:
-
- cnop 0,4
-
- The start of a program and of each section is always guaranteed
- to be longword aligned.
-
- <label> DC.B expression<,expression> ...
- <label> DC.W expression<,expression> ...
- <label> DC.L expression<,expression> ...
-
- These directives define constants in memory. They may have
- one or more operands, separated by commas. The constants will be
- aligned on word boundaries for DC.W and DC.L no more than 128
- bytes can be generated by a single DC directive.
- DC.B treats strings slightly different to those in normal
- expressions. While the rules described previously about quotation
- marks still applies. No padding of the bytes will occur, and the
- length of any string can be upto 128 bytes.
- Be very careful of spaces in any DC directives, as a space is
- the delimiter before a comment. For example, the line
-
- dc.b 1,2,3 ,4
-
- will only generate 3 bytes - the ,4 will be taken as a comment.
-
- <label> DS.B expression
- <label> DS.W expression
- <label) DS.L expression
-
- These directives will reserve memory locations and the
- contents will be initialised to zeros. If there is a label then it
- will be set to the start of the area defined, which will be on a
- word boundary for DS.W and DS.L directives. There is no
- restriction on the size though the larger the area the longer it
- will take to save to disk.
-
- For example, all of these lines will reserve 8 bytes of space,
- in different ways :
-
- ds.b 8
- ds.w 4
- ds.l 2
-
- <label> DCB.B number,value
- <label> DCB.W number,value
- <label> DCB.L number,value
-
- This directive allows constant blocks of data to be generated
- of the size specified, number specifies how many times the value
- should be repeated.
-
- FAIL
- This directive will produce the error user error. It can be
- used for such things as warning the programmer if an incorrect
- number of parameters have been passed to a macro.
-
- OUTPUT filename
- This directive sets the normal output filename though can be
- overridden by specifying a filename at the start of assembly. If
- filename starts with a period then it is used as an extension and
- the output name is built up as described previously.
-
- __G2 (reserved symbol)
- This is a reserved symbol that can be used to detect whether
- GenST is being used to assemble a file using the IFD conditional.
- The value of this symbol depends on the version of the assembler
- and is always absolute.
-
- REPEAT LOOPS
- It is often useful to be able to repeat one or more
- instructions a particular number of times and the repeat loop
- construct allows this.
-
- <label> REPT expression
- ENDR
-
- Lines to be repeated should be enclosed within REPT and ENDR
- directives and will be repeated the number of times specified in
- the expression. If the expression is zero or negative then no code
- will be generated. It is not possible to nest repeat loops. For
- example
-
- REPT 512/4 copy a sector quickly
- move.l (a0)+,(a1)+
- ENDR
-
- NOTE: Program labels should not be define within repeat loops
- to prevent label defined twice errors.
-
- LISTING CONTROL
-
- LIST
- This will turn the assembly listing on during pass 2, to
- whatever device was selected at the start of the assembly (or to
- the screen of None was initially chosen). All subsequent lines
- will be listed until an END directive is reached, the end of the
- text is reached, or a Nolist directive is encountered.
- Greater control over listing sections of program can be
- achieved using LIST+ or LIST- directives. A counter is maintained,
- the state of which dictates whether listing is on or off. A LIST+
- directive adds one to the counter and a LIST- subtracts one. If
- the counter is zero or positive then listing is on, if it is
- negative then listing is off. The default starting value is -1
- (i.e. listing off) unless a listing is specified when the
- assembler was invoked, when it is set to zero. This system allows
- a considerable degree of control over listing particularly for
- include files. The normal LIST directive sets the counter to 0,
- NOLIST sets it to -1.
-
- NOLIST
- This will turn off any listing during pass 2.
-
- When a listing is requested onto a printer or to disk, the
- output is formatted into pages, with a header at the top of every
- page. The header itself consists of a line containing the program
- title, date, time and page number, then a line showing the program
- title, then a line showing the sub-title, then a blank line. The
- date format will be printed in the form DD/MM/YY, unless the
- assembler is running on a US Atari ST, then it is MM/DD/YY.
- Between pages a form-feed character (ASCII FF, value 12) is
- issued.
-
- PLEN expression
- This will set the page length of the assembly listing and
- defaults to 60. The expression must be between 12 and 255.
-
- LLEN expression
- This will set the line width of the assembly listing and
- defaults to 132. The value of the expression must be between 38
- and 255.
-
- TTL string
- This will set the title printed at the top of each page to
- the given string, which may be enclosed in single quotes. The
- first TTL directive will set the title of the first printed page.
- If no title is specified the current include file name will be
- used.
-
- SUBTTL string
- Sets the subtitle printed at the top of each page to the
- given string, which may be enclosed in single quotes. The first
- such directive will set the sub-title of the first printed page.
-
- SPC expression
- This will output the number of blank lines given in the
- expression in the assembly listing, if active.
-
- PAGE
- Causes a new page in the listing to be started.
-
- LISTCHAR expression<,expression> ...
- This will send the characters specified to the listing device
- (except the screen) and is intended for doing things such as
- setting condensed mode on printers. For example, on Epsons and
- compatibles the line
-
- listchar 15
-
- will set the printer to 132-column mode.
-
- FORMAT parameter<,parameter> ...
- This allows exact control over the listed format of a line of
- source code. Each parameter controls a field in the listing and
- must consist of a digit from 0 to 2 inclusive followed by a + (to
- enable the field) or a - (to disable it):
-
- 0 line number, in decimal
- 1 section name/number and program counter
- 2 hex data words, up to 10 words unless printer is less than 80
- characters wide, when up to three words are listed.
-
- LABEL DIRECTIVES
-
- label EQU expression
-
- This directive will set the value and type of the given label
- to the results of the expression. It may not include forward
- references, or external labels. If there is any error in the
- expression, the assignment will not be made. The label is
- compulsory and must not be a local label.
-
- label = expression
-
- Alternate form of EQU statement
-
- label EQUR register
-
- This directive allows a data or address register to be
- referred to by a user-name, supplied as the label to this
- directive. This is known as a register equate. A register equate
- must be defined before it is used.
-
- label SET expression
-
- This is similar to EQU, but the assignment is only temporary
- and can be changed with a subsequent SET directive. Forward
- references cannot be used in the expression. It is especially
- useful for counters within macros, for example, using a line
-
- zcount set zcount+1
-
- (assuming zcount is set to 0 at the start of the source). At the
- start of pass 2 all SET labels are made undefined, so their values
- will always be the same on both passes
-
- label REG register-list
-
- This allows a symbol to be used to denote a register list
- within MOVEM instructions, reducing the likelihood of having the
- list at the start of a routine different from the list at the end
- of the routine. A label defined with REG can only be used in MOVEM
- instructions.
-
- <label> RS.B expression
- <label> RS.W expression
- <label> RS.L expression
-
- These directives let you set up lists of constant labels,
- which is very useful for data structures and global variables and
- is best illustrated by a couple of examples
- Let's assume you have a data structure which consists of a
- long word, a byte and another long word, in that order. To make
- your code more readable and easier to update should the structure
- change, you could use lines such as:
-
- rsreset
- d_next rs.l 1
- d_flag rs.b 1
- d_where rs.l 1
-
- and then you could access them with lines like
-
- move.l d_next(a0),a1
- move.l d_where(a0),a2
- tst.b d_flag(a0)
-
- As another example let's assume you are referencing all your
- variables off register A6 (as done in GenAM and MonAM) you could
- define them with lines such as
-
- onstate rs.b 1
- start rs.l 1
- end rs.l 1
-
- you then could reference them with lines such as
-
- move.b onstate(a6),d1
- move.l start(a6),d0
- cmp.l end(a6),d0
-
- Each such directive uses its own internal counter, which is reset
- to 0 at the beginning of each pass. Every time the assembler comes
- across the directive it sets the label according to the current
- value (with word alignment if it is .W or .L) then increments it
- according to the size and magnitude of the directive. If the above
- definitions were the first RS directives, onstate would be 0,
- start would be 2 and end would be 6.
-
- RSRESET
- This directive will reset the internal counter as used by the RS
- directive.
-
- RSSET expression
- This allows the RS counter to be set to a particular value.
-
- __RS (reserved symbol)
- This is a reserved symbol having the current value of the RS
- counter.
-
- CONDITIONAL ASSEMBLY
- Conditional assembly allows the programmer to write a
- comprehensive source program that can cover many conditions.
- Assembly conditionals may be specified through the use of
- arguments, in the case of macros, and through the definition of
- symbols in EQU or SET directives. Variations in these can then
- cause assembly of only those parts necessary for the specified
- conditions.
- There are a wide range of directives concerned with
- conditional assembly. At the start of the conditional blocks there
- must be one of many IF directives and at the end of each block
- there must be an ENDC directive. Conditional blocks may be nested
- up to 65535 levels.
- Labels should not be placed on IF or ENDC directives as the
- directives will be ignored by the assembler.
-
- IFEQ expression
- IFNE expression
- IFGT expression
- IFGE expression
- IFLT expression
- IFLE expression
-
- These directives will evaluate the expression, compare it with
- zero and then turn the conditional assembly on or off depending on
- the result. The conditions correspond exactly to the 68000
- condition codes. For example, if the label DEBUG had the value 1,
- then with the following code,
-
- IFEQ DEBUG
- logon dc.b 'enter a command:'.0
- ENDC
- IFNE DEBUG
- opt d+ labels please
- logon dc.b 'Yeah, gimme man:',0
- ENDC
-
- the first conditional would turn assembly off as 1 is not EQ to 0,
- while the second conditional would turn it on as 1 is NE to 0.
-
- NOTE: IFNE corresponds to IF in assemblers with only one
- conditional directive.
- The expressions used in these conditional statements must
- evaluate correctly.
-
- IFD label
- IFND label
- These directives allow conditional control depending on
- whether a label is defined or not. With IFD, assembly is switched
- on if the label is defined, whereas with IFND assembly is switched
- on if the label is not defined. These directives should be used
- with care otherwise different object codes could be generated on
- pass 1 and pass 2 which will produce incorrect code and generate
- phasing errors. Both directives also work on reserved symbols.
-
- IFC 'string1','string2'
- This directive will compare two strings, each of which must
- be surrounded by single quotes. If they are identical assembly is
- switched on, else it i switched off. The comparison is case
- sensitive.
-
- IFNC 'string1','string2'
- This directive is similar to the above, but only switches
- assembly on if the strings are not identical. This may at first
- appear somewhat useless, but when one or both of the parameters are
- macro parameters it can b every useful, as shown in the next section.
-
- ELSEIF
- This directive toggles conditional assembly from on to off,
- or vice versa.
-
- ENDC
- This directive will terminate the current level of
- conditional assembly. If there are more IF's then ENDC's an error
- will be reported at the end of assembly.
-
- IIF expression instruction
- This is a short form of the IFNE directive allowing a single
- instruction or directive to be assembled conditionally. No ENDC
- should be used with IIF directives.
-
- MACRO OPERATIONS
- GenAM fully supports Motorola-style macros, which together with
- conditional assembly allows you greatly to simplify assembly-
- language programming and the readability of your code.
- A macro is a way for a programmer to specify a whole sequence
- of instructions or directives that are used together very
- frequently. A macro is first defined, then its name can be used in
- a macro call like a directive with up to 36 parameters.
-
- label MACRO
- This starts a macro definition and causes GenAM to copy all
- following lines to a macro buffer until an ENDM directive is
- encountered. Macro definitions may not be nested.
-
- ENDM
- This terminates the storing of a macro definition, after a MACRO
- directive.
-
- MEXIT
- This stops prematurely the current macro expansion and is best
- illustrated by the INC example given later.
-
- NARG (reserved label)
- This is not a directive but a reserved symbol, Its value is the
- number of parameters passed to the current macro, or 0 if used
- when not within any macro. If GenAM is in the case sensitive mode
- then the name should be all upper-case.
-
- MACRO PARIMETERS
- Once a macro has been defined with the Macro directive it can
- be invoked by using its name as a directive, followed by upto 36
- parameters. In the macro itself the parameters may be referred to
- by using a backslash character (\) followed by an alpha-numeric
- (1-9, A-Z or a-z) which will be replaced with the relevant
- parameter when expanded or with nothing if no parameter was given.
- There is also the special macro parameter \0 which is the size
- appended to the macro call and defaults to W if none is given. If
- a macro parameter is to include spaces or commas then the
- parameter should be enclosed in between < and > symbols; in this
- case a > symbol may be included within the parameters by
- specifying >>.
- A special form of macro expansion allows the conversion of a
- symbol to a decimal or hexadecimal sequence of digits, using the
- syntax \<symbol> or \$<symbol>, the latter denoting hex expansion.
- The symbol mast be defined and absolute at the time of expansion.
- The parameter \@ can be useful for generating unique labels
- with each macro call and is replaced when the macro is expanded by
- the sequence _nnn where nnn is a number which increases by one
- with every macro call. It may be expanded up to 5 digits for
- very large assemblies.
- A true \ may be included in a macro definition by specifying \\.
-
- A macro call may be spread over more than one line,
- particularly useful for macros with large numbers of parameters.
- This can be done by ending a macro call with a comma then
- starting the next line with an & followed by tabs or spaces then
- the continuation of the parameters.
- In the assembly listing the default is to show just the macro
- call and not the code produced by it. However, macro expansion
- listings can be switched on and off using the OPT M directive
- described previously.
- Macro calls may be nested as deeply as memory permits,
- allowing recursion if required.
- Macro names are stored in a separate symbol table to normal
- symbols so will not clash with similarly named routines, and may
- start with a period.
-
- MACRO EXAMPLES
-
- EXAMPLE 1 - CALLING A LIBRARY
- As the first example, a common way of calling an Amiga library
- routine is:
-
- save register a6
- load a6 from a library pointer
- do a jsr with offset
- restore a6
-
- A macro to follow the above specifications could be:
-
- call_lib MACRO
- move.l a6,-(sp)
- move.l \2,a6 get lib pointer
- jsr _LVO\l(a6) call it
- move.l (sp)+,a6 restore
- ENDM
-
- The directives are in capitals only to make them stand out: they
- don't have to be. If you wanted to call this macro to use the DOS
- function Output the code would be:
-
- call_lib Output,_DOSbase
-
- When this macro call is expanded, \1 is replaced with Output and
- \2 is replaced with _DOSbase. \0, if it occurred in the macro, would
- be W as no size is given on the call. So the above call would be
- assembled as:
-
- move.l a6,-(sp)
- move.l _DOSbase,a6 get lib pointer
- jsr _LVOOutput(a6) call it
- move.l (sp)+,a6 restore a6
-
- EXAMPLE 2 - AN INC INSTRUCTION
- The 68000 does not have the INC instruction like other
- processors but the same effect can be achieved using an ADDQ #1
- instruction. A macro may be used to do this, like so:
-
- inc MACRO
- IFC '','\1'
- fail missing parameter!
- MEXIT
- ENDC
- addq.\0 #1,\1
- ENDM
-
- An example call would be
-
- inc.1 a0
-
- which would expand to
-
- addq.1 #1,a0
-
- The macro starts by comparing the first parameter with an empty
- string and causing an error message to be issued using FAIL if it
- is equal. The MEXIT directive is used to leave the macro without
- expanding the rest of it. Assuming there is a non-null parameter,
- the next line does the ADDQ instruction, using the \0 parameter to
- get the correct size.
-
- EXAMPLE 3 - A FACTORIAL MACRO
- Although unlikely actually to be used as it stands, this macro
- defines a label to be the factorial of a number. It shows how
- recursion can work in macros. Before showing the macro, it is
- useful to examine how the same thing would be done in a high level
- language such as Pascal.
-
- function factor(n:integer):integer;
- begin
- if n>0 then
- factor:=n*factor(n-1)
- else
- factor:=1
- end;
-
- The macro definition for this uses the SET directive to do the
- multiplication n*(n-1)*(n-2) etc. in this way
-
- * parameter 1= label, parameter 2= 'n'
- factor MACRO
- IFND \1
- \1 set 1 set if not yet defined
- ENDC
- IFGT \2
- factor \1,\2-1 work out next level down
- \1 set \1*(\2) n = n * factor(n-1)
- ENDC
- ENDM
- * a sample call
- factor test,3
-
- The net result of the previous code is to set test to 3! (3
- factorial). The reason the second set has (\2) instead of just \2
- is that the parameter will not normally be just a simple
- expression, but a list of numbers separated by minus signs, so it
- could assemble to:
-
- test set test*5-1-1-1
-
- (i.e. test*5-3) instead of the correct
-
- test set test*(5-1-1-1)
-
- (i.e. test *2)
-
- EXAMPLE 4 - CONDITIONAL RETURN INSTRUCTION
- The 68000 lacks the conditional return instruction found on other
- processors, but macros can be defined to implement them using the
- \@ parameter. For example, a return if EQ macro could look like:
-
- rtseq MACRO
- bne.s \@
- rts
- \@
- ENDM
-
- The \@ parameter has been used to generate a unique label every
- time the macro is called, so will generate in this case labels
- such as _002 and _017.
-
- EXAMPLE 5 - NUMERIC SUBSTITUTION
- Suppose you have a constant containing the version number of
- your program and wish it to appear as ASCII in a message:
-
- showname MACRO
- dc.b \1,'\<version>',0
- ENDM
- .
- .
- version equ 42
- showname <'Real Ale Search Program v'>
-
- will expand to the line
-
- dc.b 'Real Ale Search Program v','42',0
-
- Note the way the string parameter is enclosed in < >s as it
- contains spaces.
-
- EXAMPLE 6 - COMPLEX MACRO CALL
- Suppose your program needs a complicated table structure which
- can have a varying number of fields. A macro can only be written to
- using those parameters that are specified, for example:
-
- table_entry macro
- dc.b .end\0-* length byte
- dc.b \1 always
- IFNC '\2',''
- dc,w \2,\3 2nd and 3rd together
- ENDC
- dc.l \4,\5,\6,\7
- IFNC '\8',''
- dc.b '\8' text
- ENDC
- dc.b \9
- .end\@ dc.b 0
- ENDM
-
- * a sample call
- table_entry &42,,,t1,t2,t3,t4,
- & <Enter Name:>,%0110
-
- NOTE: THE NEXT 2 PAGES ARE MISSING FROM MY PHOTOCOPY (THANX REB!) SO
- I'LL HAVE TO IMPROVISE.. I'LL MARK WHERE IT'S BACK FROM THE MANUAL.
-
- This is a non-trivial example of how macros can make a
- programmer's life so much easier when dealing with complex data
- structures. In this case the table consists of a length byte,
- calculated in the macro using \@, two optional words, four longs,
- an optional string, a byte, then a zero byte. The code produced in
- this example would be :
-
- dc.b .end_001
- dc.b $42
- dc.l t1,t2,t3,t4
- dc,b 'Enter Name:'
- dc,b %0110
- .end_001 dc.b 0
-
- OUTPUT FILE FORMATS
- GenAM is very flexible in terms of output file formats. These
- are detailed in this section together with notes on the advantages
- and disadvantages of each. Certain directives take different
- actions, depending on what output file format is specified.
-
- The exact details of using each format will now be described.
-
- EXECUTABLE FILES
- These are directly executable, for example, by double
- clicking from the workbench, or from the CLI. The file may include
- relocation information and/or symbolic information.
-
- ADVANTAGES
- true BSS sections, reduced development time.
-
- DISADVANTAGES
- messy if more than one programmer.
-
- GST LINKABLE FILES
- When writing larger programs, or when writing assembly
- language modules for use from the high level language, a
- programmer needs to generate a linkable file. The GST link format
- is supported by most of the high level languages produced in
- Britain as well as others, for example HiSoft Basic, Lattice C,
- Prospero Fortran and Prospero Pascal. GST format files normally
- have the extension .BIN.
-
- ADVANTAGES
- Great degree of freedom - imported labels can be
- used practically anywhere including within arbitrary expressions,
- libraries can be created from the assembler, import methods means
- the assembler can detect type conflicts.
-
- DISADVANTAGES
- Library format means selective library linking can
- be slow, true AmigaDOS sections not supported as standard.
-
- CHOOSING THE RIGHT FILE FORMAT
- If you wish to link with a high level language there isn't
- usually much choice - you have to use whichever format is
- supported by the language.
- If you are writing entirely in assembly language then the
- normal choice has to be executable - it is fast to assemble, no
- linking required, and allows assembly to memory for decreased
- development time.
- If you are writing a larger program, say bigger than 32k
- object, or writing a program as a team, then linkable code often
- makes most sense. We recommend GST-linkable over DRI because of
- the much greater flexibility of the format.
-
- OUTPUT FILE DIRECTIVES
- This section details those directives whose actions depend on
- the output file format chosen. The file format itself can be
- chosen by one of the following methods; command line options using
- GENST2.TTP; clicking on the radio buttons in the Assembly Options
- dialogue box from the editor, or with the OPT L directive at the
- beginning of the source file.
-
- Icons are used to denote those sections specific to a file format,
- viz
-
- *EXEC* Executable-code, also assembled to memory code.
-
- *GST* GST-linkable code
-
- *DRI* DRI-linkable code.
-
- BACK TO THE MANUAL, HOPE I GOT IT RIGHT, shit! THE NEXT BIT IS VERY
- DIFFERANT SO THE ABOVE IS PROBABLY WRONG! PARASITE 4.26am
-
- SECTIONS
-
- SECTION string<,type>
- This defines a switch to the named section and optionally
- defines it's type. A program may consist of several sections which
- will be concentrated together with other sections of the same name in
- the final executable file. This will use the supplied string and type
- as the section name and type of this section (of hunk) respectivly.
- Each can be up to 32 characters long and should not include tabs or
- spaces or be enclosed in quotes. The casing of the name is
- significant. You may have many SECTION directives in your program.
- The type can be one of the following (in upper or lower case):
-
- CODE code section, public memory
- CODE_F code section, Fast memory
- CODE_C code section, chip memory
- DATA data section, public memory
- DATA_F data section, fast memory
- DATA_C data section, chip memory
- BSS BSS section, public memory
- BSS_F BSS section, fast memory
- BSS_C BSS section, chip memory
-
- CODE sections are used for executable instructions, DATA sections
- for initialised data (constants), and BSS for un-initialised data. BSS
- sections have the advantage that they take no disk space - only the
- length of the BSS section is stored. If you define a section to be BSS
- you can only use the directive to produce code - any other code
- generating instructions will cause a binary file i/o error.
- NOTE: Do not use types requesting chip or fast memory, with
- versions prior to version 2.3 of the Alink linker - these versions
- will crash!
-
- CODE/DATA/BSS
- These directives are supported for compatability with the Amiga
- macro assembler. They are the same as specifying the directive as the
- section name and type.
-
- IDNT string
- This will use the supplied name as the hunk unit name for this
- section, It can be up to 32 characters long and should not include
- tabs or spaces or be enclosed in quotes.
-
- IMPORTS AND EXPORTS
- With both linkable types of program it is crucial to be able
- to import and export symbols, both relative symbols (i.e. program
- references) and absolute symbols (i.e. constants). The AmigaDOS
- linker format does not distinguish between these types; however by
- specifying the type when importing, the assembler can type check,
- often finding programming errors that would otherwise be missed.
-
- XDEF export<,export>...
- This defines labels for export to other programs (or
- modules). If any of the labels specified are not defined an error
- will occur. It is not possible to export local labels.
-
- EXEC
- This directive is ignored
-
- XREF import<,import>...
- XREF.L import<,import>...
- This defines labels to be imported from other programs or
- modules. If any of the labels specified are defined an error will
- occur. The normal XREF statement should be used to import a
- relative label (i.e. program reference), while XREF.L should be
- used to import absolute labels (i.e. constants). If you do not type
- your imports you should turn type-checking off using OPT T-
- Importing a label more than once will not produce an error.
-
- EXEC
- This directive is ignored
-
- USING IMPORTS IN EXPRESSIONS
-
- EXEC
- There are no imports! However referances to labels in other
- sections are subject to the limitations described below.
-
- LINK
- Imports may be used in expressions but only one import
- per expression is allowed. The results of an expression with an
- import in must be of the form import+number or import-number.
- Imports can be combined with arbitrarily complex expressions, so
- long as the complex expression lexically precedes it, for example
-
- move.l 3+(1<<count+5)+import
-
- EXPRESSION GST DRI EXAMPLE
- byte Y N move.b #test,do
- word Y Y move.w test(a3),d0
- long Y Y move.l test,d0
-
- COMMENT comment string
-
- This directive is ignored at present
-
- ORG expression
- This will make the assembler generate position dependant code
- and set the program counter to the given value. Normal AmigaDOS
- program,s do not need an ORG statement even if position dependant.
- It is included to allow code to be generated for the ROM port or
- for other 68000 machines. More than one ORG statement is allowed
- in a source file but no padding of the file is done.
-
- EXEC
- It should be used with great care as the binary file
- generated will probably not execute correctly when double clicked.
- as no relocation information is written out. The binary file
- produced has the standard AmigaDOS header at the front, but no
- relocation information.
-
- LINK
- This directive is not allowed.
-
- OFFSET <expression>
- This switches code generation to a special section to
- generate absolute labels. The optional expression sets the program
- counter for the start of this section. No bytes are written to the
- disk and the only code generating directive allowed is DS. Labels
- defined in this section will be absolute. For example, to define
- some of the system variables of the ST. (This is in the AMIGA
- manual!);
-
- offset $400
- etv_timer ds.l 1 will be $400
- etv_critic ds.l 1 404
- etv_term ds.l 1 408
- ext_extra ds.l 5 40C
- memvalid ds.l 1 420
- memcntlr ds.w 1 424
-
- __LK (reserved symbol)
- This is a reserved symbol that can be used to detect which
- output mode is specified. The value of this symbol is alwayus
- absolute and one of the following:
-
- 3 linkable
- 4 executable
-
- Values 0-2 are reserved for the production of ST code; other
- values and the high word are reserved for future expansion.
-
- RETURN CODES
- When using the stand alone assembler from within batch files or
- make files, it's return code can be used to determine the success of
- the assembly. Values returned are:
-
- 100+ initialisation failure
- 20 fatal error
- 5 warnings
- 0 OK
-
- DIRECTIVE SUMMARY
-
- ASSEMBLY CONTROL
- END terminate source code
- INCLUDE read source file from disk
- INCBIN read binary file from disk
- OPT option control
- EVEN ensure PC even
- CNOP align PC arbitrarily
- DC define constant
- DS define space
- DCB define constant block
- FAIL force assembly error
-
- REPEAT LOOPS
- REPT start repeat block
- ENDR end repeat block
-
- LISTING CONTROL
- LIST enable list
- NOLIST disable list
- PLEN set page length
- LLEN set line length
- TTL set title
- SUBTTL set sub-title
- PAGE start new page
- LISTCHAR send control character
- FORMAT define listing format
-
- LABEL DIRECTIVES
- EQU define label value
- EQUR define register equate
- SET define label value temporarily
- REG define register list
- RS reserve space
- RSRESET reset RS counter
- RSSET set RS counter
-
- CONDITIONAL ASSEMBLY
- IFEQ assemble if zero
- IFNE assemble in non-zero
- IFGT assemble if greater than
- IFGE assemble if greater than or equal to
- IFLT assemble if less than
- IFLE assemble if less than or equal to
- IFD assemble if label defined
- IFND assemble if label not defined
- IFC assemble if strings same
- IFNC assemble if strings different
- ELSEIF switch assembly state
- IIFC immediate IF
-
- MACROS
- MACRO define macro
- ENDM end macro definition
-
- OUTPUT FILE DIRECTIVES
- MODULE start new module
- SECTION switch section
- XDEF define label for export
- XREF define label for import
- COMMENT send linker comment
- ORG set absolute code generation
- OFFSET define offset table
-
- RESERVED SYMBOLS
- NARG number of macro parameters
- __G2 internal version number
- __RS RS counter
- __LK output file type
-
- BLINK LINKER
- This version of BLINK is a public domain limker designed as a
- replacement for the standard AmigaDOS linker, Alink. The program has
- many powerful features, but in the simplest case the command line is
-
- blink (from) <infile.o> [<infile2.o>...] [ TO <outfile>]
-
- which specifies one or more input files and an output file. Normally
- all sections will be placed in seperate hunks, but they can be forced
- into one hunk by specifying SMALLCODE or SMALLDATA on the command
- line. For example;
-
- blink test.o
-
- will link test.o into the file test
-
- blink FROM start.o middle.o end.o TO total
-
- will link the specified three files into total
-
- blink FROM start.o middle.o end.o TO total SMALLCODE
-
- as above but coalescing for BLink are contained in a file on disk 2,
- which can be read on screen or printed out in the usual manor.
-
- NOW LOAD PART 2...
-